<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>帖子信息修改页面</title>
<link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.3.3/themes/default/easyui.css"></link>
<link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.3.3/themes/icon.css"></link>
<script type="text/javascript" src="/static/jquery-easyui-1.3.3/jquery.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>

<script type="text/javascript" src="/static/ckeditor/ckeditor.js"></script>
<script type="text/javascript">

	


	function submitData(){
		$("#fm").form("submit",{
			url:"/admin/film/save",
			onSubmit:function(){
				var content= CKEDITOR.instances.content.getData()
				if(content==""){
					$.messager.alert("系统提示","内容不能为空！");
					return false;
				}
				return $(this).form("validate");
			},
			success:function(result){
				var result=eval('('+result+')');
				if(result.success){
					$.messager.alert("系统提示","保存成功");
					resetValue();
				}else{
					$.messager.alert("系统提示","保存失败");

				}
			}
		});
		
	}
	
	
	function resetValue(){
		$("#name").val("");
		$("#title").val("");
		$("#imageFile").val("");
		$("#no").prop("checked", true);
		CKEDITOR.instances.content.setData("");
	}

</script>
</head>
<body style="margin: 10px">
<div id="p" class="easyui-panel" title="修改帖子" style="padding: 10px">
   <form id="fm" method="post" enctype="multipart/form-data">
 	<table cellspacing="20px">
   		<tr>
   			<td width="80px">帖子名称：</td>
   			<td><input type="text" id="name" name="name" style="width: 400px;" class="easyui-validatebox" required="true"/></td>
   		</tr>
   		<tr>
   			<td width="80px">标题：</td>
   			<td><input type="text" id="title" name="title" style="width: 400px;" class="easyui-validatebox" required="true"/></td>
   		</tr>
   		<tr>
   			<td width="80px" valign="top">帖子图片：</td>
   			<td>
   			<input type="hidden" id="imageName" name="imageName" />
   			<input type="file" id="imageFile" name="imageFile" />
   			</td>
   		</tr>
   		<tr>
   			<td width="80px">设置热门：</td>
   			<td><input type="radio" id="yes" value="1" name="hot" />是&nbsp;<input type="radio" id="no" value="0" checked="checked" name="hot" />否</td>
   		</tr>
   		<tr>
   			<td valign="top">内容：</td>
   			<td>
				 <textarea name="content" id="content" rows="30" cols="80"></textarea>
   			</td>
   		</tr>
   		<tr>
   			<td></td>
   			<td>
   				<input type="hidden" id="id" name="id" />
   				<a href="javascript:submitData()" class="easyui-linkbutton" data-options="iconCls:'icon-submit'">发布</a>
   			</td>
   		</tr>
   	</table>
   </form>
 </div>
 
<script>
    // Replace the <textarea id="editor1"> with a CKEditor
    // instance, using default configuration.
    CKEDITOR.replace( 'content' );
    
    function getQueryString(name) {  
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");  
		var url=decodeURI(decodeURI(window.location.search))  
		var r = url.substr(1).match(reg);  
		if (r != null) return unescape(r[2]); return null;  
	}
	

	var id=getQueryString("id");
	$.post("/admin/film/findById",{id:id},function(result){
		$("#id").val(result.id);
		$("#name").val(result.name);
		$("#title").val(result.title);
		$("#imageName").val(result.imageName);
		if(result.hot==1){
			$("#yes").prop("checked", true);
		}else{
			$("#no").prop("checked", true);
		}
		CKEDITOR.instances.content.setData(result.content);
	},"json");

</script>
</body>
</html>